package src

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"goft/src/goft"
)

type User struct {
	number int `uri:"id" binding:"required,gt=0"`
}

func NewUser() *User {
	return &User{}
}

func (this *User) String() string {
	return fmt.Sprintf("number:%d", this.number)
}

func usercontext(c *gin.Context) goft.Model {
	user := NewUser()
	goft.Error(c.BindUri(*user), "参数错误")
	fmt.Println(user.number)
	return user
}

func (this *User) Build(g *goft.Goft) {
	g.Handle("GET", "/user/:id", usercontext)
}
